package com.wing.order.model.entity;

import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.wing.mybatis.common.BaseEntity;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 配货需求订单表
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("ord_distribution_demand")
public class DistributionDemand extends BaseEntity<DistributionDemand> implements Serializable {

    private static final long serialVersionUID = 1L;

    public enum Status implements IEnum<Integer> {

        /**
         * 已驳回
         */
        rejected(-1,"已驳回"),

        /**
         * 已创建
         */
        created(0,"已创建"),
        /**
        * 待受理
        */
        pending(1,"待受理"),
        /**
        * 已受理
        */
        accepted(2,"已受理"),
        /**
        * 配货中
        */
        inDelivery(3,"配货中"),
        /**
        * 配送中
        */
        deliverGoods(4,"配送中"),
        /**
        * 已签收
        */
        haveBeenReceived(5,"已签收"),
        /**
        * 完成
        */
        finish(6,"完成"),


        loadPlanFinish(7,"上货计划已配额完");

        private int code;
        private String desc;

        Status(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }


    public enum Type implements IEnum<Integer> {

        /**
         * 告警配货需求单
         */
        alarm(0,"告警配货需求单"),
        /**
         * 1临时配货需求单
         */
        temp(1,"临时配货需求单");

        private int code;
        private String desc;

        Type(int code,String desc){
            this.code=code;
            this.desc=desc;
        }

        @Override
        public Integer getValue(){
            return this.code;
        }

        public String getDesc(){
            return this.desc;
        }
    }


    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 配货订单编号
     */
    private String distCode;

    /**
     * 客户名称
     */
    private String customerName;

    /**
     * 客户联系人
     */
    private String customerConcat;

    /**
     * 联系人电话
     */
    private String customerMoble;

    /**
     * 刀具补货数量
     */
    private Long addNum;

    /**
     * 刀柜SKU库存数量
     */
    private Long stockNum;

    /**
     * 补货刀柜数量
     */
    private Long cabNum;

    /**
     * 货值
     */
    private BigDecimal total;

    /**
     * 企业id
     */
    private Long enterpriseId;

    @TableField(exist = false)
    private String enterpriseCode;

    /**
     * 省
     */
    private Long province;

    /**
     * 市
     */
    private Long city;

    /**
     * 区
     */
    private Long area;

    /**
     * 详情地址
     */
    private String address;

    /**
    * 确认时间
    */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime confirmTime;

    /**
     * 状态
     */
    private Status status;

    /**
    * 状态描述
    */
    @TableField(exist = false)
    private String statusDesc;

    public String getStatusDesc() {
        return status == null ? null : status.getDesc();
    }

    /**
     * 商品单位id
     */
    private Long unitId;

    /**
     * 商品单位名称
     */
    private String unitName;

    /**
     * 车间id
     */
    private Long workshopId;

    /**
     * 车间名称
     */
    private String workshopName;


    private Type type;

    @TableField(exist = false)
    private String typeDesc;

    public String getTypeDesc(){
        if (type!=null){
            return type.getDesc();
        }
        return null;
    }


    private Integer day;

    private Integer no;

    /**
     * sku数
     */
    private Long cabSkuNum;



    /**
     * 审核时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime auditTime;

    /**
     * 审核人ID
     */
    private Long auditorId;

    /**
     * 审核人名称
     */
    private String auditorName;

    /**
     * 审核意见
     */
    private String auditRemark;

    @TableField(exist = false)
    private String uniqCode;
    @TableField(exist = false)
    private Long idOfEnterprise;

    @TableField(exist = false)
    private List<DistributionDemandDetail> dfList;

    @TableField(exist = false)
    private String code;
}
